Page({
  data: {
    bgd1: "",
    bgd2: "",
    bgd3: "",
    bgd4: "",
    bgd5: "",
    bgd6: "",
    bgd7: "",
    bgd8: "",
    bgd9: "",
    bgd10: "",
    bgd11: "",
    bgd12: "",
    bgd13: "",
    bgd14: "",
    bgd15: "",
    bgd16: "",
    bgd17: "",
    bgd18: "",
    bgd19: "",
    bgd20: "",
    bgd21: "",
    bgd22: "",
    bgd23: "",
    bgd24: "",
    bgd25: "",
    bgd26: "",
    bgd27: "",
    bgd28: "",
  },
  onLoad:  function () {
    console.log("order进来");
    //wx.clearStorage();
   var that=this; 
   wx.getStorage({
     key: 'key1',
     success: function (res) {
       console.log(res.data);
       var bathid = res.data;
       if (bathid == "001") {
         that.setData({
           bgd1: "green"
         });
       }
       if (bathid == "002") {
         that.setData({
           bgd2: "green"
         });
       }
       if (bathid == "003") {
         that.setData({
           bgd3: "green"
         });
       }
       if (bathid == "004") {
         that.setData({
           bgd4: "green"
         });
       }
       if (bathid == "005") {
         that.setData({
           bgd5: "green"
         });
       }
       if (bathid == "006") {
         that.setData({
           bgd6: "green"
         });
       }
       if (bathid == "007") {
         that.setData({
           bgd7: "green"
         });
       }
       if (bathid == "008") {
         that.setData({
           bgd8: "green"
         });
       }
       if (bathid == "009") {
         that.setData({
           bgd9: "green"
         });
       }
       if (bathid == "010") {
         that.setData({
           bgd10: "green"
         });
       }
       if (bathid == "011") {
         that.setData({
           bgd11: "green"
         });
       }
       if (bathid == "012") {
         that.setData({
           bgd12: "green"
         });
       }
       if (bathid == "013") {
         that.setData({
           bgd13: "green"
         });
       }
       if (bathid == "014") {
         that.setData({
           bgd14: "green"
         });
       }
       if (bathid == "015") {
         that.setData({
           bgd15: "green"
         });
       }
       if (bathid == "016") {
         that.setData({
           bgd16: "green"
         });
       }
       if (bathid == "017") {
         that.setData({
           bgd17: "green"
         });
       }
       if (bathid == "018") {
         that.setData({
           bg18: "green"
         });
       }
       if (bathid == "019") {
         that.setData({
           bgd19: "green"
         });
       }
       if (bathid == "020") {
         that.setData({
           bgd20: "green"
         });
       }
       if (bathid == "021") {
         that.setData({
           bgd2: "green"
         });
       }
       if (bathid == "022") {
         that.setData({
           bgd22: "green"
         });
       }
       if (bathid == "023") {
         that.setData({
           bgd23: "green"
         });
       }
       if (bathid == "024") {
         that.setData({
           bgd24: "green"
         });
       }
       if (bathid == "025") {
         that.setData({
           bgd25: "green"
         });
       }
       if (bathid == "026") {
         that.setData({
           bgd26: "green"
         });
       }
       if (bathid == "027") {
         that.setData({
           bgd27: "green"
         });
       }
       if (bathid == "028") {
         that.setData({
           bgd28: "green"
         });
       }

     },
   })
   wx.request({
     url: 'https://www.szz5.com/admin/selectAll',
     method:'POST',
     data:{},
     success:function(res){
    console.info("++++++++++=1",JSON.stringify(res));
     var list=res.data;
     console.info("++++++++++=2", JSON.stringify(list));
     if(list != null){
       for (var index in list) {
         console.info("++++++++++=3", list[index]);
         var bathid=list[index];
         if (bathid == '001') {
           console.info("进来001");
           that.setData({            
             bgd1: "red"             
           });         
         }
         if (bathid == "002") {
           console.info("进来002");
           that.setData({
             bgd2: "red"
           });
         }
         if (bathid == "003") {
           that.setData({
             bgd3: "red"
           });
         }
         if (bathid == "004") {
           that.setData({
             bgd4: "red"
           });
         }
         if (bathid == "005") {
           that.setData({
             bgd5: "red"
           });
         }
         if (bathid == "006") {
           that.setData({
             bgd6: "red"
           });
         }
         if (bathid == "007") {
           that.setData({
             bgd7: "red"
           });
         }
         if (bathid == "008") {
           that.setData({
             bgd8: "red"
           });
         }
         if (bathid == "009") {
           that.setData({
             bgd9: "red"
           });
         }
         if (bathid == "010") {
           that.setData({
             bgd10: "red"
           });
         }
         if (bathid == "011") {
           that.setData({
             bgd11: "red"
           });
         }
         if (bathid == "012") {
           that.setData({
             bgd12: "red"
           });
         }
         if (bathid == "013") {
           that.setData({
             bgd13: "red"
           });
         }
         if (bathid == "014") {
           that.setData({
             bgd14: "red"
           });
         }
         if (bathid == "015") {
           that.setData({
             bgd15: "red"
           });
         }
         if (bathid == "016") {
           that.setData({
             bgd16: "red"
           });
         }
         if (bathid == "017") {
           that.setData({
             bgd17: "red"
           });
         }
         if (bathid == "018") {
           that.setData({
             bg18: "red"
           });
         }
         if (bathid == "019") {
           that.setData({
             bgd19: "red"
           });
         }
         if (bathid == "020") {
           that.setData({
             bgd20: "red"
           });
         }
         if (bathid == "021") {
           that.setData({
             bgd2: "red"
           });
         }
         if (bathid == "022") {
           that.setData({
             bgd22: "red"
           });
         }
         if (bathid == "023") {
           that.setData({
             bgd23: "red"
           });
         }
         if (bathid == "024") {
           that.setData({
             bgd24: "red"
           });
         }
         if (bathid == "025") {
           that.setData({
             bgd25: "red"
           });
         }
         if (bathid == "026") {
           that.setData({
             bgd26: "red"
           });
         }
         if (bathid == "027") {
           that.setData({
             bgd27: "red"
           });
         }
         if (bathid == "028") {
           that.setData({
             bgd28: "red"
           });
         }
       }
      
      // wx.showToast({
      //   title: '获取数据失败',      
      //   duration: 1500      
      // })
     }
     }
   })
  },
  gotoresult:  function (e) {
    var ID = e.currentTarget.id;   
    console.log("idd", ID);
    // wx.clearStorage("userInfo");
   var stor= wx.getStorageSync("userInfo");
   var getkey = wx.getStorageSync("key1");
  if(stor==null || stor==""){
    console.log("stor"+stor);
    wx.showModal({
      title: '提示',
      content: '您没有激活状态，请去激活',
      success: function (res) {
        if (res.confirm) {
          console.log('用户点击确定');

          wx.hideToast()
          wx.switchTab({
            url: '../../login/login'
          })
         
          console.log('1');
          // return;
        } else if (res.cancel) {
          console.log('用户点击取消');
          return;
        }
      }
    })  
  } else if (getkey) {
    wx.showModal({
      title: '提示',
      content: '您已经选择过！',
      success: function (res) {
        if (res.confirm) {
          console.log('用户点击确定');
          return;
        } else if (res.cancel) {
          console.log('用户点击取消');
          return;
        }
      }
    })  
    
  }else{
  
    wx.request({
      url: 'https://www.szz5.com/admin/byBathId',
      method: 'POST',
      data: {bathId :ID},
      success: function (res) { 
        console.info("++++++++++=4", JSON.stringify(res));
           if(res.data== '1'){
             wx.showModal({
               title: '提示',
               content: '此澡位已被预订！',
               success: function (res) {
                 if (res.confirm) {
                   console.log('用户点击确定');
                   return;
                 } else if (res.cancel) {
                   console.log('用户点击取消');
                   return;
                 }
               }
             })  
           }
      }

    })
    wx.showModal({
      title: '提示',
      content: '是否预定该位置',
      success: function (res) {
        if (res.confirm) {
          console.log('用户点击确定');
          wx.setStorageSync("keykey", ID);
          wx.navigateTo({
            url: '../../seltime/seltime',
          })
          return;
        } else if (res.cancel) {
          console.log('用户点击取消');
          return;
        }
      }
    })

  }
    // wx.getStorage({
    //   key: 'key',
    //   success: function (res) {
    //     console.log(res.data);
    //     if(res){
    //       console.log(res);
         
    //       return;
    //     }
    //   },
    // });
    

   
  }


  
})